package cn.getech.data.development.mapper;

import cn.getech.data.development.entity.BdpDataCategory;
import cn.getech.data.development.entity.TableInfo;
import cn.getech.data.development.entity.flink.BdpRealTableInfo;
import cn.getech.data.development.model.dto.ProjectListDTO;
import cn.getech.data.development.model.dto.real.RealTableQueryDTO;
import cn.getech.data.development.model.dto.real.RealTableQueryReturnDTO;
import cn.getech.data.development.model.vo.BdpDataCategoryTableInfoVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;


/**
 * 类目信息表Mapper接口
 *
 * @author bianj
 * @version 1.0.0 2020-09-29
 */
@Mapper
public interface BdpDataCategoryMapper extends BaseMapper<BdpDataCategory> {

    /**
     * 查询当前目录id下存在的表数据
     */
    IPage<BdpDataCategoryTableInfoVO> selectListByTableInfo(@Param("params") Map<String, Object> params, @Param("offIds") List<Integer> offIds);

    /**
     * 统计
     */
    Integer selectListByTableInfoCount(@Param("params") Map<String, Object> params);

    /**
     * 判断目录下是否有表
     */
    List<Integer> selectDataCategory(@Param("params") Map<String, Object> params);

    Integer selectUserIdByuserName(@Param("userName") String userName);

    /***查询没有类目信息的表数据*/
    List<BdpDataCategoryTableInfoVO> selectListByNotTableInfo(@Param("params") Map<String, Object> params);

    List<BdpDataCategoryTableInfoVO> selectByTableInfo(@Param("params") Map<String, Object> params);

    /**
     * 统计
     */
    Integer selectListByNotTableInfoCount(@Param("params") Map<String, Object> params);

    /***查询自己关联类目的表*/
    List<Integer> selectMyMeDataCategoryTableInfo(@Param("id") Integer id);

    List<Integer> selectMyMeInfoTable(@Param("id") Integer id);

    /**
     * 当前用户的项目成员所有表
     */
    List<Integer> selectProcTable(@Param("id") Integer id);

    /**
     * 查询是否存在数据
     */
    Integer selectCategoryTableCount(@Param("params") Map<String, Object> params);

    /**
     * 批量插入数据
     */
    void saveBdpDataCategoryByIds(@Param("params") List<BdpDataCategoryTableInfoVO> BdpDataCategoryTableInfo);

    /**
     * 批量删除数据
     **/
    void deleteBdpDataCategoryByIds(@Param("params") List<BdpDataCategoryTableInfoVO> BdpDataCategoryTableInfo);

    /**
     * 分页查询表的创建人
     */
    List<String> selectTableInfoCrateName(@Param("params") Map<String, Object> params);

    /***分页查询项目列表*/
    List<String> selectProcList(@Param("params") Map<String, Object> params);

    /**
     * 查询数据库
     */
    List<String> selectDBTable(@Param("params") Map<String, Object> params);

    ArrayList<String> getProjectNamesByTableId(@Param("id") Integer id);

    List<Integer> selectTableIds(@Param("params") Map<String, Object> paster);

    List<Integer> selectRealTableIds(@Param("params") Map<String, Object> paster);

    IPage<RealTableQueryReturnDTO> getRealTable(IPage<RealTableQueryReturnDTO> page, @Param("tableQueryDTO") RealTableQueryDTO tableQueryDTO, @Param("params") Map<String, Object> paramsMap);

   List<Integer> selectMyRealTable( @Param("id") Integer id, @Param("tenantId") Integer tenantId);

    List<Integer> selectTotal(@Param("params") Map<String, Object> params, @Param("offIds") List<Integer> offIds);

    IPage<BdpDataCategoryTableInfoVO>  selectByPage(IPage<BdpDataCategoryTableInfoVO> page1,
                                                    @Param("tableType") String tableType,
                                                    @Param("tenantId") Integer tenantId);

    ArrayList<String> selectCategoryName( @Param("tableId") Integer tableId,  @Param("tenantId") Integer tenantId);

    TableInfo selectTables(Integer tableId);

    ArrayList<String> selectProName(@Param("tableId") Integer tableId,@Param("tableType") Integer tableType);

    BdpRealTableInfo selectRealTableInfo(Integer tableId);

    ArrayList<String> selectProNameByResourceId(Integer resourceId);

    IPage<BdpDataCategoryTableInfoVO> selectPageList(IPage<BdpDataCategoryTableInfoVO> page1,@Param("params") Map<String, Object> paster);

    List<String> selectProjectName(Integer tableType);

    List<Long> getTableInfoCrateName(@Param("params") Map<String, Object> params);

    List<Long> getRealTableUsers(@Param("params") Map<String, Object> params);

    IPage<RealTableQueryReturnDTO> getRealTableInfo(IPage<RealTableQueryReturnDTO> page, @Param("tableQueryDTO") RealTableQueryDTO tableQueryDTO, @Param("params") Map<String, Object> paramsMap);


    Integer selectRealTable(Integer tableId);

    List<BdpDataCategoryTableInfoVO> projectList(@Param("tenantId") Integer tenantId);

    Set<ProjectListDTO> selectProNameList(Integer tableId);

    Set<String> getProjectByTableId(@Param("params") Map<String, Object> params);

    List<RealTableQueryReturnDTO> selectRealTableProName(@Param("params") Map<String, Object> params);

    Set<String> selectRealProName(@Param("params") Map<String, Object> params);

    List<Map> getTableByCategoryIdAndDb(@Param("params")Map<String, Object> params);
}